<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui" >
    <h:head>
        <link rel="shortcut icon" href="Imagenes/database_mysql.ico" type="image/x-icon"/>
        <meta name="viewport" content="width=device-width"/>
    </h:head>
    <h:body>
        <h:form id="form">
            <h:panelGrid style="margin: 0 auto">
                <p:outputLabel value="ADMINISTRACION DE SCHEMAS" style="color: #2480BC;"/>
                <br></br>
                <br></br>
            </h:panelGrid>
            <p:growl id="growl2" autoUpdate="true" showDetail="true" life="10000"/>
            <p:tabView dynamic="true"  id="tabViewDB" activeIndex="#{tableBean.index}" >
                
                <p:tab title="Crear y Seleccionar un Schema" disabled="#{tableBean.disabledParent}">
                    <h:panelGrid style="margin: 0 auto;font-size: 15px" columns="5" >      
                        <h:outputText value="Crear un Schema:"/>
                        <p:inputText id="firstname" value="#{tableBean.bdname}" 
                                     label="Firstname" style="width: 200px;"/>
                        <p:selectOneMenu value="#{tableBean.value}" style="width: 200px;" id="so"> 
                            <f:selectItem itemLabel="Character Set" itemValue="" />
                            <f:selectItems value="#{tableBean.collates}" var="collate" itemLabel="#{collate}" itemValue="#{collate}"/>  
                        </p:selectOneMenu>
                        <p:commandButton value="Crear" action="#{tableBean.createDB()}" style="width: 100px;" update="tables,firstname"/>
                        <br></br>
                        <br></br>
                    </h:panelGrid>
                        <h:panelGrid style="margin: 0 auto" id ="tableDB">
                            <p:dataTable id = "tables" var = "obj" value="#{tableBean.mediumSchemasModel}" selection="#{tableBean.selectedSchema}">
                                <p:column selectionMode="single" style="width:2%"/>
                                <p:column style="width: 10px"  headerText="Schema">
                        #{obj.name}
                                </p:column>
                            </p:dataTable> 
                            <br></br>
                            <br></br>
                        </h:panelGrid>
                    <br></br>
                    <h:panelGrid style="margin: 0 auto" columns="2" >
                        <p:commandButton value="Ver Elementos" 
                                         action="#{tableBean.changeTab}" 
                                         update="tabViewDB"/>
                        <p:commandButton value="Drop" style="color: #2480BC;" action="#{tableBean.singleDrop()}" update="tables">
                            <p:confirm header="Confirmation" message="Esta Seguro de Realizar Esta accion?" icon="ui-icon-alert" /> 
                        </p:commandButton>   
                        <p:confirmDialog global="true" showEffect="fade" hideEffect="explode">  
                            <p:commandButton value="Yes" type="button" update="tables" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />  
                            <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>       
                        </p:confirmDialog> 
                    </h:panelGrid>
                </p:tab >
                
                   
                <p:tab title="Listado de Tablas"  disabled="#{tableBean.disabled}">
                    <h:panelGrid style="margin: 0 auto" columns="1">
                        <p:dataTable id="tableTables" var="table" 
                                     value="#{tableBean.tables}" style="text-align: center">
                            <p:column headerText="Tablas Base de Datos #{tableBean.schemaName}">  
                                <h:outputText value="#{table}" />  
                            </p:column> 
                        </p:dataTable>
                    </h:panelGrid>
                    
                    <h:panelGrid style="margin: 0 auto" columns="3" >
                        <p:commandButton value="Drop" style="color: #2480BC;"  action="#{tableBean.drop()}" update="tabViewDB">
                            <p:confirm header="Confirmation" message="Esta Seguro de Realizar Esta accion?" icon="ui-icon-alert" /> 
                        </p:commandButton>   
                        <p:confirmDialog global="true" showEffect="fade" hideEffect="explode">  
                            <p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />  
                            <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>       
                        </p:confirmDialog>
                        <p:commandButton value="Cancelar" 
                                         action="#{tableBean.cancel}" 
                                         update="tabViewDB"/>
                    </h:panelGrid>
                </p:tab>
                
                
                
                <p:tab title="Listado de Funciones"  disabled="#{tableBean.disabled}">
                    
                  <h:panelGrid style="margin: 0 auto" columns="1">
                        <p:dataTable id="tableFunctions" var="table" 
                                     value="#{tableBean.functions}" style="text-align: center">
                            <p:column headerText="Funciones Base de Datos #{tableBean.schemaName}">  
                                <h:outputText value="#{table}" />  
                            </p:column> 
                        </p:dataTable>
                    </h:panelGrid>
                    
                    <h:panelGrid style="margin: 0 auto" columns="3" >
                        <p:commandButton value="Drop" style="color: #2480BC;"  action="#{tableBean.drop()}" update="tabViewDB">
                            <p:confirm header="Confirmation" message="Esta Seguro de Realizar Esta accion?" icon="ui-icon-alert" /> 
                        </p:commandButton>   
                        <p:confirmDialog global="true" showEffect="fade" hideEffect="explode">  
                            <p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />  
                            <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>       
                        </p:confirmDialog>
                        <p:commandButton value="Cancelar" 
                                         action="#{tableBean.cancel}" 
                                         update="tabViewDB"/>
                    </h:panelGrid>
                </p:tab>
                
                
                
                
                <p:tab title="Listado de Triggers"  disabled="#{tableBean.disabled}">
                    <h:panelGrid style="margin: 0 auto" columns="1">
                        <p:dataTable id="tableTriggers" var="table" 
                                     value="#{tableBean.triggers}" style="text-align: center">
                            <p:column headerText="Triggers Base de Datos #{tableBean.schemaName}">  
                                <h:outputText value="#{table}" />  
                            </p:column> 
                        </p:dataTable>
                    </h:panelGrid>
                    <h:panelGrid style="margin: 0 auto" columns="3" >
                        <p:commandButton value="Drop" style="color: #2480BC;"  action="#{tableBean.drop()}" update="tabViewDB">
                            <p:confirm header="Confirmation" message="Esta Seguro de Realizar Esta accion?" icon="ui-icon-alert" /> 
                        </p:commandButton>   
                        <p:confirmDialog global="true" showEffect="fade" hideEffect="explode">  
                            <p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />  
                            <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>       
                        </p:confirmDialog>
                        <p:commandButton value="Cancelar" 
                                         action="#{tableBean.cancel}" 
                                         update="tabViewDB"/>
                    </h:panelGrid>
                </p:tab>
                
                
                
                
                <p:tab title="Listado de Procedimientos"  disabled="#{tableBean.disabled}">
                   <h:panelGrid style="margin: 0 auto" columns="1">
                        <p:dataTable id="tableProcedures" var="table" 
                                     value="#{tableBean.procedures}" style="text-align: center">
                            <p:column headerText="Procedimientos Base de Datos #{tableBean.schemaName}">  
                                <h:outputText value="#{table}" />  
                            </p:column> 
                        </p:dataTable>
                    </h:panelGrid>
                    <h:panelGrid style="margin: 0 auto" columns="3" >
                        <p:commandButton value="Drop" style="color: #2480BC;"  action="#{tableBean.drop()}" update="tabViewDB">
                            <p:confirm header="Confirmation" message="Esta Seguro de Realizar Esta accion?" icon="ui-icon-alert" /> 
                        </p:commandButton>   
                        <p:confirmDialog global="true" showEffect="fade" hideEffect="explode">  
                            <p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />  
                            <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>       
                        </p:confirmDialog>
                        <p:commandButton value="Cancelar" 
                                         action="#{tableBean.cancel}" 
                                         update="tabViewDB"/>
                    </h:panelGrid>
                </p:tab>
                
                
                <p:tab title="Listado de Indices"  disabled="#{tableBean.disabled}">
                     <h:panelGrid style="margin: 0 auto" columns="1">
                        <p:dataTable id="tableIndexs" var="table" 
                                     value="#{tableBean.indexs}" style="text-align: center">
                            <p:column headerText="Indices Base de Datos #{tableBean.schemaName}">  
                                <h:outputText value="#{table}" />  
                            </p:column> 
                        </p:dataTable>
                    </h:panelGrid>
                    <h:panelGrid style="margin: 0 auto" columns="3" >
                        <p:commandButton value="Drop" style="color: #2480BC;"  action="#{tableBean.drop()}"  update="tabViewDB">
                            <p:confirm header="Confirmation" message="Esta Seguro de Realizar Esta accion?" icon="ui-icon-alert" /> 
                        </p:commandButton>   
                        <p:confirmDialog global="true" showEffect="fade" hideEffect="explode">  
                            <p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />  
                            <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>       
                        </p:confirmDialog>
                        <p:commandButton value="Cancelar" 
                                         action="#{tableBean.cancel}" 
                                         update="tabViewDB"/>
                    </h:panelGrid>
                </p:tab>
                
                
            </p:tabView>
    
        <!-- CAR DIALOGS -->
         <h:form id="create">
                        <p:dialog header="Atencion!!" 
                                  widgetVar="carDialog3" 
                                  position="center" 
                                  modal="false"    
                                  visible="false" 
                                  showEffect="explode" 
                                  hideEffect="explode" 
                                  resizable="true" 
                                  closable="false" 
                                  style="text-align:center;margin: 0 auto;">  
                            <p:outputPanel id="carDetail" style="text-align:center;margin: 0 auto;" layout="block">   
                                <h:panelGrid>  
                                    <h:outputText value = "#{tableBean.message}" id="mess2" />
                                    <p:commandButton value="Aceptar" update="" oncomplete="carDialog3.hide()" />
                                </h:panelGrid>  
                            </p:outputPanel>  
                        </p:dialog>
                    </h:form>
        <h:form id="drop">
            <p:dialog header="Atencion!!" 
                      widgetVar="carDialog2" 
                      position="center" 
                      modal="false"  
                      visible="false" 
                      showEffect="explode" 
                      hideEffect="explode" 
                      resizable="true" 
                      closable="false" 
                      style="text-align:center;margin: 0 auto;">  
                <p:outputPanel id="carDetail" style="text-align:center;margin: 0 auto;" layout="block">   
                    <h:panelGrid>  
                        <h:outputText value = "#{tableBean.message}" id="mess"/>
                        <p:commandButton value="Aceptar"  update="" oncomplete="carDialog2.hide()" style="margin: 0 auto"/>
                    </h:panelGrid>  
                </p:outputPanel>  
            </p:dialog>
        </h:form>

        </h:form>
    </h:body>
</html>


